﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace WOTLauncher
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            /**
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
            */

            if (MainForm.HandleRunningInstance() == false)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                var updater = FSLib.App.SimpleUpdater.Updater.Instance;
                //当检查发生错误时,这个事件会触发   
                updater.Error += new EventHandler(updater_Error);
                //没有找到更新的事件    
                updater.NoUpdatesFound += new EventHandler(updater_NoUpdatesFound);

                //找到更新的事件.但在此实例中,找到更新会自动进行处理,所以这里并不需要操作    
                //updater.UpdatesFound += new EventHandler(updater_UpdatesFound);     
                //开始检查更新-这是最简单的模式.请现在 assemblyInfo.cs 中配置更新地址,参见对应的文件.   

                FSLib.App.SimpleUpdater.Updater.CheckUpdateSimple("http://wotrate.vicp.co/wot/update.xml");
                MainForm form = new MainForm();
                Application.Run(form);
            }

        }


        static void updater_UpdatesFound(object sender, EventArgs e)
        {
        }
        static void updater_NoUpdatesFound(object sender, EventArgs e)
        {
            //System.Windows.Forms.MessageBox.Show("没有找到更新");
        }
        static void updater_Error(object sender, EventArgs e)
        {
            var updater = sender as FSLib.App.SimpleUpdater.Updater;
            System.Windows.Forms.MessageBox.Show(updater.Exception.ToString());
        }

    }
}
